/*
 * Dat215projektView.java
 */

package dat215projekt;

import dat215projekt.data.IMatDataHandlerExtended;
import dat215projekt.gui.components.HomePanel;
import javax.swing.ImageIcon;
import org.jdesktop.application.Action;
import org.jdesktop.application.SingleFrameApplication;
import org.jdesktop.application.FrameView;
import javax.swing.JDialog;
import javax.swing.JFrame;
import org.jdesktop.application.ResourceMap;

/**
 * The application's main frame.
 */
public class Dat215projektView extends FrameView {

    public Dat215projektView(SingleFrameApplication app) {
        super(app);

        initComponents();
        ResourceMap r = Dat215projektApp.getApplication().getContext().getResourceMap(Dat215projektView.class);

        ImageIcon frameIcon = r.getImageIcon("frame.icon");
        this.getFrame().setIconImage(frameIcon.getImage());

        // Fulhaxx
        navigation1.setPanelRef(panelen);
        navigation1.setPaneRef(tabbedPane1.getPane());

        checkOut1.setNavigationRef(navigation1);
        checkOut1.setTabbedPaneRef(tabbedPane1.getPane());

        shoppingCartCard1.setNavigationRef(navigation1);
        IMatDataHandlerExtended.getInstance().fireShoppingCartChanged();

        HomePanel.getInstance().setButtonsRefs(tabbedPane1.getHomeButton3(), tabbedPane1.getHomeButton4());


    }

    public void shutdown(){
        tabbedPane1.getPane().setSelectedIndex(0);
    }

    @Action
    public void showAboutBox() {
        if (aboutBox == null) {
            JFrame mainFrame = Dat215projektApp.getApplication().getMainFrame();
            aboutBox = new Dat215projektAboutBox(mainFrame);
            aboutBox.setLocationRelativeTo(mainFrame);
        }
        Dat215projektApp.getApplication().show(aboutBox);
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        mainPanel = new javax.swing.JPanel();
        shoppingCart1 = new dat215projekt.gui.components.ShoppingCart();
        navigation1 = new dat215projekt.gui.components.Navigation();
        panelen = new javax.swing.JPanel();
        tabbedPane1 = new dat215projekt.gui.components.TabbedPane();
        shoppingCartCard1 = new dat215projekt.gui.components.ShoppingCartCard();
        checkOut1 = new dat215projekt.gui.components.CheckOut();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();

        org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(dat215projekt.Dat215projektApp.class).getContext().getResourceMap(Dat215projektView.class);
        mainPanel.setBackground(resourceMap.getColor("mainPanel.background")); // NOI18N
        mainPanel.setName("mainPanel"); // NOI18N

        shoppingCart1.setName("shoppingCart1"); // NOI18N

        navigation1.setName("navigation1"); // NOI18N

        panelen.setName("panelen"); // NOI18N
        panelen.setOpaque(false);
        panelen.setLayout(new java.awt.CardLayout());

        tabbedPane1.setName("tabbedPane1"); // NOI18N
        panelen.add(tabbedPane1, "card2");

        shoppingCartCard1.setName("shoppingCartCard1"); // NOI18N
        panelen.add(shoppingCartCard1, "card4");

        checkOut1.setName("checkOut1"); // NOI18N
        panelen.add(checkOut1, "card3");

        jLabel1.setText(resourceMap.getString("jLabel1.text")); // NOI18N
        jLabel1.setName("jLabel1"); // NOI18N

        jLabel2.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
        jLabel2.setIcon(resourceMap.getIcon("jLabel2.icon")); // NOI18N
        jLabel2.setText(resourceMap.getString("jLabel2.text")); // NOI18N
        jLabel2.setVerticalAlignment(javax.swing.SwingConstants.TOP);
        jLabel2.setName("jLabel2"); // NOI18N

        javax.swing.GroupLayout mainPanelLayout = new javax.swing.GroupLayout(mainPanel);
        mainPanel.setLayout(mainPanelLayout);
        mainPanelLayout.setHorizontalGroup(
            mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(mainPanelLayout.createSequentialGroup()
                .addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(mainPanelLayout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jLabel2)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jLabel1))
                    .addComponent(shoppingCart1, javax.swing.GroupLayout.PREFERRED_SIZE, 324, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(panelen, javax.swing.GroupLayout.DEFAULT_SIZE, 934, Short.MAX_VALUE)
                .addContainerGap())
            .addComponent(navigation1, javax.swing.GroupLayout.DEFAULT_SIZE, 1274, Short.MAX_VALUE)
        );
        mainPanelLayout.setVerticalGroup(
            mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(mainPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(mainPanelLayout.createSequentialGroup()
                        .addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(mainPanelLayout.createSequentialGroup()
                                .addGap(47, 47, 47)
                                .addComponent(jLabel1))
                            .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 176, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(shoppingCart1, javax.swing.GroupLayout.DEFAULT_SIZE, 994, Short.MAX_VALUE))
                    .addComponent(panelen, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 1181, Short.MAX_VALUE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(navigation1, javax.swing.GroupLayout.PREFERRED_SIZE, 111, javax.swing.GroupLayout.PREFERRED_SIZE))
        );

        setComponent(mainPanel);
    }// </editor-fold>//GEN-END:initComponents

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private dat215projekt.gui.components.CheckOut checkOut1;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JPanel mainPanel;
    private dat215projekt.gui.components.Navigation navigation1;
    private javax.swing.JPanel panelen;
    private dat215projekt.gui.components.ShoppingCart shoppingCart1;
    private dat215projekt.gui.components.ShoppingCartCard shoppingCartCard1;
    private dat215projekt.gui.components.TabbedPane tabbedPane1;
    // End of variables declaration//GEN-END:variables


    private JDialog aboutBox;
}
